package com.communal.web.form.cr;

import net.sf.ezmorph.bean.MorphDynaBean;
import net.sf.json.JSONObject;

import com.communal.model.cr.CRInternet;

/**
 * 
 * @author Created by andrey.kuznetsov <br>
 * @author Last modified by $Author$ <br>
 * @author Last modified on $Date$ at revision $Revision$ <br>
 */
public class CRInternetForm extends CRForm{

	private final String CURRENT_VALUE = "currentValue";
	private final String ADVANCED_SUMMA = "advancedSumma";
	private final String TARIF_ID = "tarifId";
	
	private Short currentValue;
	private Double advancedSumma;
	private Integer tarifId;
	
	/**
	 * Constructor from JSON data for {@link CRInternetForm} <br>
	 * @param p_data - JSON data
	 */
	public CRInternetForm(Object p_data) {
		super( p_data, true );
		JSONObject jsonObject = JSONObject.fromObject(p_data);
		MorphDynaBean bean = (MorphDynaBean) JSONObject.toBean(jsonObject);
		currentValue = Short.parseShort(bean.get(CURRENT_VALUE).toString());
		advancedSumma = Double.parseDouble(bean.get(ADVANCED_SUMMA).toString());
		tarifId = (Integer) bean.get(TARIF_ID);
	}
	
	/**
	 * Constructor for {@link CRInternetForm} from electricity entity <br>
	 * @param p_communalRecord {@link CRInternet}
	 * @param p_monthYear
	 */
	public CRInternetForm(CRInternet p_internet, String p_monthYear) {
		super( p_internet, p_monthYear );
		currentValue = p_internet.getCurrentValue();
		advancedSumma = p_internet.getAdvancedSumma();
		tarifId= p_internet.getTarif().getId();
	}

	/**
	 * Returns current traffic in Mb <br>
	 * @return {@link Short};
	 */
	public Short getCurrentValue() {
		return currentValue;
	}

	/**
	 * Sets current traffic in Mb <br>
	 * @param p_currentValue - {@link Short};
	 */
	public void setCurrentValue(Short p_currentValue) {
		currentValue = p_currentValue;
	}

	/**
	 * Returns summa for advanced services <br>
	 * @return {@link Double};
	 */
	public Double getAdvancedSumma() {
		return advancedSumma;
	}

	/**
	 * Sets summa for advanced services <br>
	 * @param p_advancedSumma - {@link Double};
	 */
	public void setAdvancedSumma(Double p_advancedSumma) {
		advancedSumma = p_advancedSumma;
	}

	/**
	 * Returns tarif id <br>
	 * @return {@link Integer};
	 */
	public Integer getTarifId() {
		return tarifId;
	}

	/**
	 * Sets tarif id <br>
	 * @param p_tarifId - {@link Integer};
	 */
	public void setTarifId(Integer p_tarifId) {
		tarifId = p_tarifId;
	}
	
	
}
